package com.lzw.mapper.admin;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

@Mapper
public interface AdminMapper {

    @Select("SELECT admin_id FROM dormitorymanagement.systemadmin WHERE username = #{username} AND password = #{password}")
    Integer checkCredentials(@Param("username") String username, @Param("password") String password);

    @Select("SELECT admin_id, name, username,phone, email FROM dormitorymanagement.systemadmin WHERE username = #{username} AND password = #{password}")
    Map<String, Object> getAdmin(@Param("username") String username, @Param("password") String password);

    @Select("SELECT admin_id, name, username, phone, email FROM dormitorymanagement.systemadmin WHERE admin_id = #{adminId}")
    Map<String, Object> getAdminById(@Param("adminId") Integer adminId);

    @Update("UPDATE dormitorymanagement.systemadmin SET name = #{name}, phone = #{phone}, email = #{email} WHERE admin_id = #{adminId}")
    int updateAdmin(@Param("adminId") Integer adminId, @Param("name") String name,
                    @Param("phone") String phone, @Param("email") String email);
}
